/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PCrearmapa.java
 *
 * Created on 20-sep-2011, 23:15:59
 */
package View.Almacen.AdministrarRack;
import javax.swing.*;
import java.awt.*;


import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;




/**
 *
 * @author Michael
 */
public class PModificarRack extends JPanel implements MouseListener{

    JButton botones[][];
    JButton boton;
    public PModificarRack() {
        
        //llenarMapa();
        
    }
    public void llenarMapa(int ancho,int alto){
        this.removeAll();
        setLayout(null);
        setLayout(new GridLayout(alto,ancho));
        //setSize(500,500);
        botones=new JButton[alto][ancho];
        for (int i=0;i<alto;i++){
                for(int j=0;j<ancho;j++){
                    boton= new JButton(" ");//+(i+1)+"-"+(j+1));
                    boton.setSize(20,20);     
                    boton.setBackground(Color.yellow);
                    boton.setFocusPainted(false);
                    botones[i][j]=boton;                
                    boton.addMouseListener(new MouseAdapter(){
                    public void mousePressed(MouseEvent e) {
                            if (((JButton)e.getSource()).getBackground()==Color.yellow){                                 
                                ((JButton)e.getSource()).setBackground(Color.black);
                            }
                            else
                                ((JButton)e.getSource()).setBackground(Color.yellow);
                    }});
                }
        }        
        for (int i=0;i<alto;i++){
                for(int j=0;j<ancho;j++){
                     add(botones[i][j]);
                }
        }
        
    }
    @Override
    public void mouseClicked(MouseEvent me) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void mousePressed(MouseEvent me) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void mouseReleased(MouseEvent me) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void mouseEntered(MouseEvent me) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void mouseExited(MouseEvent me) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    

}
